package com.gxgeek.rabbitmqspring;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import static com.gxgeek.rabbitmqspring.RabbitMqConfig.QUEUENAME;

/**
 * @author gaoxing
 * @create 2018-05-17 下午3:22
 */
@Component
@Slf4j
// 监听“hello”队列
//@RabbitListener(queues ="hello")
public class Receiver {

//    @RabbitListener(queues ="hello-spring")
//    @RabbitHandler
//    // handler注解来指定对消息的处理方法
//    public void process(String hello) {
//
//        System.out.println("Receiver:" + hello);
//
//    }

    @RabbitListener(queuesToDeclare= @Queue(QUEUENAME))//监听并创建队列
//    @RabbitListener(queues = "myQueue")//只监听队列
//    @RabbitListener(queuesToDeclare= @Queue("myQueue"))//监听并创建队列
//    @RabbitListener(bindings = @QueueBinding(
//            exchange = @Exchange("myExchange"),
//            value = @Queue("myQueue"))
//    )//exchange 和 队列绑定

    public void proessProductInfo(String message){
        log.info("接受消息:{}",message);
    }



}

